<!doctype html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../vendor/bootstrap-icons/font/bootstrap-icons.css">
    <link rel="stylesheet" href="../vendor/bootstrap/dist/css/bootstrap.min.css">
    <title>bs</title>

<body>

<div class="container p-2">
    <div class="row">
        <div class="col-md-6">
            <div class="qtab1"></div>
            <button class="btn btn-success btn1 mt-2">添加tab</button>
        </div>
    </div>
</div>


<script src="../vendor/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="../vendor/jquery/dist/jquery.min.js"></script>
<script src="../vendor/bootstrap-quicktab/dist/js/bootstrap-quicktab.min.js"></script>

<script>
    $(function () {

        var qtab = new Quicktab({
            selector: '.qtab1',
            tabs: [
                {title: '页面一', url: 'welcome.html?a=1'},
                {title: '页面二', url: 'welcome.html?a=2'},
                {title: '页面三', url: 'welcome.html?a=3'},
            ],
            //工具栏配置项
            toolbar: {
                //启用下拉菜单
                moreDropdowns: {
                    //启用下拉菜单功能
                    enable: true,
                    //下拉菜单的项目
                    items: {
                        //回到当前
                        rollback: {
                            //启用
                            enable: true,
                            text: '<i class="bi bi-eye me-2"></i>显示当前'
                        },
                        //刷新当前
                        reload: {
                            //不启用
                            enable: false
                        },
                        //关闭当前
                        close: {
                            //不启用
                            enable: false
                        },
                        //关闭其它
                        closeOthers: {
                            //启用
                            enable: true,
                            //同时修改文本
                            text: '<i class="bi bi-x-square me-2"></i>关闭其它'
                        },
                        //关闭所有
                        closeAll: {
                            //启用
                            enable: true,
                            text: '<i class="bi bi-x-circle me-2"></i>关闭所有'
                        }
                    }
                },
            },
            //tab的相关配置
            tabConfig: {
                //右键菜单配置
                contextmenu: {
                    //启用右键菜单功能
                    enable: true,
                    //右键菜单的项目配置
                    items: {
                        reload: {
                            enable: true,
                            text: '<i class="bi bi-arrow-clockwise"></i>重载'
                        },
                        close: {
                            enable: true,
                            text: '<i class="bi bi-x"></i>关闭'
                        },
                        //关闭其它的菜单项目不显示
                        closeOthers: {
                            enable: false,
                        }
                    }
                },
            }
        });

        $('.btn1').on('click', function () {
            var num = Math.round(Math.random() * (100000 - 1) + 1);
            qtab.addTab({
                //标题
                title: "首页" + num,
                //连接
                url: 'welcome.html?randow=' + num,
                //是否可以关闭
                close: true,
            })
        })

    })


</script>

</body>
</html>
